﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.IO;
using System.Data.SqlClient;

using System.Reflection;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace GTA.ResourceAccess
{
    public class Configuration : BaseResourceAccess
    {
        private String GetSystemConfigurationFullPath(BusinessEntity.UserManagement.User user)
        {
            String localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            String baseDirectory = Path.Combine(localAppData, @"BMFBovespa\GTA\" + user.Login);

            if (!Directory.Exists(baseDirectory))
                Directory.CreateDirectory(baseDirectory);

            String path = ConfigurationManager.AppSettings["SystemConfigurationFile"];
            return Path.Combine(baseDirectory, path);
        }
        public BusinessEntity.Configuration.SystemConfiguration GetSystemConfiguration(BusinessEntity.UserManagement.User user)
        {
            String path = GetSystemConfigurationFullPath(user);
            if (File.Exists(path))
                return Common.Util.Deserialize(path, typeof(BusinessEntity.Configuration.SystemConfiguration)) as BusinessEntity.Configuration.SystemConfiguration;
            else
                return new BusinessEntity.Configuration.SystemConfiguration();
        }
        public void SaveSystemConfiguration(BusinessEntity.Configuration.SystemConfiguration systemConfiguration, BusinessEntity.UserManagement.User user)
        {
            String path = GetSystemConfigurationFullPath(user);
            Common.Util.Serialize(path, typeof(BusinessEntity.Configuration.SystemConfiguration), systemConfiguration);
        }
        public void SaveHolidays(BusinessEntity.Configuration.Holidays holidays)
        {
            foreach (DateTime itemHoliday in holidays.Holiday)
            {
                sqlCommand = "PRC_TB_HOLIDAYS_IN";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@THHOLIDAY", itemHoliday);
                ExecuteNonQuery(sqlCommand, parameters);
            }
        }
        public void DeleteHolidays(BusinessEntity.Configuration.Holidays holidays)
        {
            foreach (DateTime itemHoliday in holidays.Holiday)
            {
                sqlCommand = "PRC_TB_HOLIDAYS_DE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@THHOLIDAY", itemHoliday);
                ExecuteNonQuery(sqlCommand, parameters);
            }
        }
        public BusinessEntity.Configuration.Holidays GetHolidays()
        {
            BusinessEntity.Configuration.Holidays holidays = null;
            try
            {
                sqlCommand = "PRC_TB_HOLIDAYS_SE";
                SqlDataReader reader = ExecuteReader(sqlCommand);
                if (reader != null && reader.HasRows)
                {
                    holidays = new BusinessEntity.Configuration.Holidays();
                    holidays.Holiday = new List<DateTime>();
                    while (reader.Read())
                        holidays.Holiday.Add(MinValueDateTime(reader["th_holiday"]));
                }
            }
            finally
            {
                if (reader != null)
                    reader.Close();
            }

            return holidays;
        }
        public List<BusinessEntity.Configuration.Alert> ListAlerts(BusinessEntity.UserManagement.User user, BusinessEntity.Configuration.AlertFilter filter)
        {
            List<BusinessEntity.Configuration.Alert> alerts = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_SE";
                SqlParameter[] parameters = new SqlParameter[4];
                parameters[0] = new SqlParameter("@TA_USER_ID", user.ID);
                parameters[1] = new SqlParameter("@TA_STATE", filter != null ? filter.State != BusinessEntity.Configuration.AlertState.All ? (int)filter.State : (object)DBNull.Value : (object)DBNull.Value);
                parameters[2] = new SqlParameter("@TA_TYPE", filter != null ? filter.Type != BusinessEntity.Configuration.AlertType.All ? (int)filter.Type : (object)DBNull.Value : (object)DBNull.Value);
                parameters[3] = new SqlParameter("@CHECK_SLEEP", filter != null ? Convert.ToInt32(filter.CheckSleep) : (object)DBNull.Value);

                reader = ExecuteReader(sqlCommand, parameters);
                if (reader != null && reader.HasRows)
                {
                    alerts = new List<BusinessEntity.Configuration.Alert>();
                    while (reader.Read())
                        alerts.Add(FillAlertData());
                }
            }
            finally
            {
                if (reader != null)
                    reader.Close();
            }
            return alerts;
        }
        private BusinessEntity.Configuration.Alert FillAlertData()
        {
            return new BusinessEntity.Configuration.Alert()
            {
                ID = MinValueInt(reader["TA_ID"]),
                Name = MinValueString(reader["TA_NAME"]),
                SleepDate = MinValueDateTime(reader["TA_SLEEP_DATE"]),
                State = (BusinessEntity.Configuration.AlertState)MinValueInt(reader["TA_STATE"]),
                Type = (BusinessEntity.Configuration.AlertType)MinValueInt(reader["TA_TYPE"]),
                AlertNotificationTypeList = GetAlertNotificationType(MinValueInt(reader["TA_ID"]))
            };
        }
        private List<BusinessEntity.Configuration.NotificationType> GetAlertNotificationType(int alertID)
        {
            List<BusinessEntity.Configuration.NotificationType> notifications = null;
            SqlDataReader readerNotifications = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_NOTIFICATION_TYPE_SE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@TNT_ALERT_ID", alertID);
                readerNotifications = ExecuteReader(sqlCommand, parameters);
                if (readerNotifications != null && readerNotifications.HasRows)
                {
                    notifications = new List<BusinessEntity.Configuration.NotificationType>();
                    while (readerNotifications.Read())
                        notifications.Add((BusinessEntity.Configuration.NotificationType)MinValueInt(readerNotifications["TNT_TYPE"]));
                }
            }
            finally
            {
                if (readerNotifications != null)
                    readerNotifications.Close();
            }
            return notifications;
        }
        public int SaveAlert(BusinessEntity.Configuration.Alert alert, BusinessEntity.UserManagement.User user)
        {
            sqlCommand = "PRC_TB_ALERTS_IN";
            SqlParameter[] parameters = new SqlParameter[5];
            parameters[0] = new SqlParameter("@TA_NAME", alert.Name);
            parameters[1] = new SqlParameter("@TA_USER_ID", user.ID);
            parameters[2] = new SqlParameter("@TA_STATE", (int)alert.State);
            parameters[3] = new SqlParameter("@TA_SLEEP_DATE", alert.SleepDate != DateTime.MinValue ? alert.SleepDate : (object)DBNull.Value);
            parameters[4] = new SqlParameter("@TA_TYPE", (int)alert.Type);
            return (Int32)ExecuteScalar(transaction, sqlCommand, parameters);
        }
        public void SaveAlertNotificationTypes(int alertID, BusinessEntity.Configuration.NotificationType notification)
        {
            sqlCommand = "PRC_TB_ALERTS_NOTIFICATION_TYPE_IN";
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@TNT_ALERT_ID", alertID);
            parameters[1] = new SqlParameter("@TNT_TYPE", (int)notification);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        public int SaveAlertTasks(Int32 alertID, BusinessEntity.Configuration.AlertTasks alertTask)
        {
            sqlCommand = "PRC_TB_ALERTS_TASKS_IN";
            SqlParameter[] parameters = new SqlParameter[5];
            parameters[0] = new SqlParameter("@TAT_ALERT_ID", alertID);
            parameters[1] = new SqlParameter("@TAT_SCHEDULE_START_FROM", alertTask.ScheduleStartFrom != DateTime.MinValue ? alertTask.ScheduleStartFrom : (object)DBNull.Value);
            parameters[2] = new SqlParameter("@TAT_SCHEDULE_START_TO", alertTask.ScheduleStartTo != DateTime.MinValue ? alertTask.ScheduleStartTo : (object)DBNull.Value);
            parameters[3] = new SqlParameter("@TAT_SCHEDULE_END_FROM", alertTask.ScheduleEndFrom != DateTime.MinValue ? alertTask.ScheduleEndFrom : (object)DBNull.Value);
            parameters[4] = new SqlParameter("@TAT_SCHEDULE_END_TO", alertTask.ScheduleEndTo != DateTime.MinValue ? alertTask.ScheduleEndTo : (object)DBNull.Value);
            return (Int32)ExecuteScalar(transaction, sqlCommand, parameters);
        }
        public void SaveAlertTasksProjects(int alertTaskID, BusinessEntity.Project project)
        {
            sqlCommand = "PRC_TB_ALERTS_TASKS_PROJECTS_IN";
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@TATP_ALERT_TASK_ID", alertTaskID);
            parameters[1] = new SqlParameter("@TATP_PROJECT", project.Name);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        public void SaveAlertTasksUsers(int alertTaskID, BusinessEntity.UserManagement.User user)
        {
            sqlCommand = "PRC_TB_ALERTS_TASKS_USERS_IN";
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@TATU_ALERT_TASK_ID", alertTaskID);
            parameters[1] = new SqlParameter("@TATU_USER_ID", user.ID);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        public void SaveAlertTasksCategories(int alertTaskID, BusinessEntity.TaskDomain category)
        {
            sqlCommand = "PRC_TB_ALERTS_TASKS_CATEGORIES_IN";
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@TATC_ALERT_TASK_ID", alertTaskID);
            parameters[1] = new SqlParameter("@TATC_CATEGORY_ID", category.ID);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        public void SaveAlertTasksStates(int alertTaskID, BusinessEntity.TaskDomain state)
        {
            sqlCommand = "PRC_TB_ALERTS_TASKS_STATES_IN";
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@TATS_ALERT_TASK_ID", alertTaskID);
            parameters[1] = new SqlParameter("@TATS_STATE_ID", state.ID);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        public void SaveAlertTasksHistoryExcedTask(int alertTaskID, BusinessEntity.Configuration.AlertTasksHistoryExcedTask alertTasksHistoryExcedTask)
        {
            sqlCommand = "PRC_TB_ALERTS_TASKS_HISTORY_EXCED_TASK_IN";
            SqlParameter[] parameters = new SqlParameter[5];
            parameters[0] = new SqlParameter("@TATH_ALERT_TASK_ID", alertTaskID);
            parameters[1] = new SqlParameter("@TATH_WEEKEND", alertTasksHistoryExcedTask.WeekEnd);
            parameters[2] = new SqlParameter("@TATH_HOLIDAY", alertTasksHistoryExcedTask.Holidays);
            parameters[3] = new SqlParameter("@TATH_HOUR_DAY", alertTasksHistoryExcedTask.HoursDay);
            parameters[4] = new SqlParameter("@TATH_PERCENT", alertTasksHistoryExcedTask.Percent != Int32.MinValue && alertTasksHistoryExcedTask.Percent != 0 ? alertTasksHistoryExcedTask.Percent : (object)DBNull.Value);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        public void SaveAlertTasksOverdueAlert(int alertTaskID, BusinessEntity.Configuration.AlertTasksOverdueAlert alertTasksOverdueAlert)
        {
            sqlCommand = "PRC_TB_ALERTS_TASKS_OVERDUE_IN";
            SqlParameter[] parameters = new SqlParameter[6];
            parameters[0] = new SqlParameter("@TATO_ALERT_TASK_ID", alertTaskID);
            parameters[1] = new SqlParameter("@TATO_ALERT_START", alertTasksOverdueAlert.StartOverdueAlert);
            parameters[2] = new SqlParameter("@TATO_ALERT_START_DAYS", alertTasksOverdueAlert.StartOverdueDays != 0 && alertTasksOverdueAlert.StartOverdueDays != Int32.MinValue ? alertTasksOverdueAlert.StartOverdueDays : (object)DBNull.Value);
            parameters[3] = new SqlParameter("@TATO_ALERT_END", alertTasksOverdueAlert.EndOverdueAlert);
            parameters[4] = new SqlParameter("@TATO_ALERT_END_DAYS", alertTasksOverdueAlert.EndOverdueDays != 0 && alertTasksOverdueAlert.EndOverdueDays != Int32.MinValue ? alertTasksOverdueAlert.EndOverdueDays : (object)DBNull.Value);
            parameters[5] = new SqlParameter("@TATO_ALERT_END_PERCENT", alertTasksOverdueAlert.EndOverduePercent != 0 && alertTasksOverdueAlert.EndOverduePercent != Int32.MinValue ? alertTasksOverdueAlert.EndOverduePercent : (object)DBNull.Value);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        private object GetDataBaseValue<T>(T param)
        {
            return (object)param == (object)default(T) ? (object)DBNull.Value : param;
        }
        public void UpdateAlert(BusinessEntity.Configuration.Alert alert)
        {
            sqlCommand = "PRC_TB_ALERTS_UP";
            SqlParameter[] parameters = new SqlParameter[5];
            parameters[0] = new SqlParameter("@TA_ID", alert.ID);
            parameters[1] = new SqlParameter("@TA_NAME", alert.Name);
            parameters[2] = new SqlParameter("@TA_STATE", (int)alert.State);
            parameters[3] = new SqlParameter("@TA_SLEEP_DATE", alert.SleepDate != DateTime.MinValue ? alert.SleepDate : (object)DBNull.Value);
            parameters[4] = new SqlParameter("@TA_TYPE", (int)alert.Type);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        public void CleanAlertReferences(int alertID)
        {
            sqlCommand = "PRC_TB_ALERTS_CLEAN_REFERENCES";
            SqlParameter[] parameters = new SqlParameter[1];
            parameters[0] = new SqlParameter("@TA_ID", alertID);
            ExecuteNonQuery(transaction, sqlCommand, parameters);
        }
        private BusinessEntity.Configuration.AlertTasks FillAlertTaskData()
        {
            return new BusinessEntity.Configuration.AlertTasks(FillAlertData())
            {
                ScheduleStartFrom = MinValueDateTime(reader["TAT_SCHEDULE_START_FROM"]),
                ScheduleStartTo = MinValueDateTime(reader["TAT_SCHEDULE_START_TO"]),
                ScheduleEndFrom = MinValueDateTime(reader["TAT_SCHEDULE_END_FROM"]),
                ScheduleEndTo = MinValueDateTime(reader["TAT_SCHEDULE_END_TO"]),
                Projects = GetAlertTasksProjects(MinValueInt(reader["TAT_ID"])),
                Users = GetAlertTasksUsers(MinValueInt(reader["TAT_ID"])),
                Categories = GetAlertTasksCategories(MinValueInt(reader["TAT_ID"])),
                States = GetAlertTasksStates(MinValueInt(reader["TAT_ID"]))
            };
        }
        public BusinessEntity.Configuration.AlertTasksHistoryExcedTask GetAlertTasksHistoryExcedTask(int alertID)
        {
            BusinessEntity.Configuration.AlertTasksHistoryExcedTask alert = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_TASKS_HISTORY_EXCED_TASK_SE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@TA_ID", alertID);
                reader = ExecuteReader(sqlCommand, parameters);
                if (reader != null && reader.HasRows)
                {
                    reader.Read();
                    alert = new BusinessEntity.Configuration.AlertTasksHistoryExcedTask(FillAlertTaskData())
                    {
                        WeekEnd = MinValueBoolean(reader["TATH_WEEKEND"]),
                        Holidays = MinValueBoolean(reader["TATH_HOLIDAY"]),
                        HoursDay = MinValueInt(reader["TATH_HOUR_DAY"]),
                        Percent = MinValueInt(reader["TATH_PERCENT"])
                    };
                }
            }
            finally
            {
                if (reader != null)
                    reader.Close();
            }
            return alert;
        }
        public BusinessEntity.Configuration.AlertTasksOverdueAlert GetAlertTasksOverdueAlert(int alertID)
        {
            BusinessEntity.Configuration.AlertTasksOverdueAlert alert = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_TASKS_OVERDUE_SE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@TA_ID", alertID);
                reader = ExecuteReader(sqlCommand, parameters);
                if (reader != null && reader.HasRows)
                {
                    reader.Read();
                    alert = new BusinessEntity.Configuration.AlertTasksOverdueAlert(FillAlertTaskData())
                    {
                        StartOverdueAlert = MinValueBoolean(reader["TATO_ALERT_START"]),
                        StartOverdueDays = MinValueInt(reader["TATO_ALERT_START_DAYS"]),
                        EndOverdueAlert = MinValueBoolean(reader["TATO_ALERT_END"]),
                        EndOverdueDays = MinValueInt(reader["TATO_ALERT_END_DAYS"]),
                        EndOverduePercent = MinValueInt(reader["TATO_ALERT_END_PERCENT"])
                    };
                }
            }
            finally
            {
                if (reader != null)
                    reader.Close();
            }
            return alert;
        }
        private List<BusinessEntity.TaskDomain> GetAlertTasksStates(int alertTasksID)
        {
            List<BusinessEntity.TaskDomain> list = null;
            SqlDataReader readerList = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_TASKS_STATES_SE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@TAT_ID", alertTasksID);
                readerList = ExecuteReader(sqlCommand, parameters);
                if (readerList != null && readerList.HasRows)
                {
                    list = new List<BusinessEntity.TaskDomain>();
                    while (readerList.Read())
                        list.Add(new BusinessEntity.TaskDomain()
                        {
                            ID = MinValueInt(readerList["TS_ID"]),
                            Description = MinValueString(readerList["TS_DESCRIPTION"])
                        });
                }
            }
            finally
            {
                if (readerList != null)
                    readerList.Close();
            }
            return list;
        }
        private List<BusinessEntity.TaskDomain> GetAlertTasksCategories(int alertTasksID)
        {
            List<BusinessEntity.TaskDomain> list = null;
            SqlDataReader readerList = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_TASKS_CATEGORIES_SE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@TAT_ID", alertTasksID);
                readerList = ExecuteReader(sqlCommand, parameters);
                if (readerList != null && readerList.HasRows)
                {
                    list = new List<BusinessEntity.TaskDomain>();
                    while (readerList.Read())
                        list.Add(new BusinessEntity.TaskDomain()
                        {
                            ID = MinValueInt(readerList["TC_ID"]),
                            Description = MinValueString(readerList["TC_DESCRIPTION"])
                        });
                }
            }
            finally
            {
                if (readerList != null)
                    readerList.Close();
            }
            return list;
        }
        private List<BusinessEntity.UserManagement.User> GetAlertTasksUsers(int alertTasksID)
        {
            List<BusinessEntity.UserManagement.User> list = null;
            SqlDataReader readerList = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_TASKS_USERS_SE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@TAT_ID", alertTasksID);
                readerList = ExecuteReader(sqlCommand, parameters);
                if (readerList != null && readerList.HasRows)
                {
                    list = new List<BusinessEntity.UserManagement.User>();
                    while (readerList.Read())
                        list.Add(new BusinessEntity.UserManagement.User()
                        {
                            ID = MinValueInt(readerList["TU_ID"]),
                            Name = MinValueString(readerList["TU_NAME"])
                        });
                }
            }
            finally
            {
                if (readerList != null)
                    readerList.Close();
            }
            return list;
        }
        private List<BusinessEntity.Project> GetAlertTasksProjects(int alertTasksID)
        {
            List<BusinessEntity.Project> list = null;
            SqlDataReader readerList = null;
            try
            {
                sqlCommand = "PRC_TB_ALERTS_TASKS_PROJECTS_SE";
                SqlParameter[] parameters = new SqlParameter[1];
                parameters[0] = new SqlParameter("@TAT_ID", alertTasksID);
                readerList = ExecuteReader(sqlCommand, parameters);
                if (readerList != null && readerList.HasRows)
                {
                    list = new List<BusinessEntity.Project>();
                    while (readerList.Read())
                        list.Add(new BusinessEntity.Project()
                        {
                            Name = MinValueString(readerList["TATP_PROJECT"])
                        });
                }
            }
            finally
            {
                if (readerList != null)
                    readerList.Close();
            }
            return list;
        }
        public void DeleteAlert(int alertID)
        {
            sqlCommand = "PRC_TB_ALERTS_DE";
            SqlParameter[] parameters = new SqlParameter[1];
            parameters[0] = new SqlParameter("@TA_ID", alertID);
            ExecuteNonQuery(sqlCommand, parameters);
        }
        public void UpdateAlertState(int alertID, global::GTA.BusinessEntity.Configuration.AlertState notificationState)
        {
            sqlCommand = "PRC_TB_ALERTS_STATE_UP";
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@TA_ID", alertID);
            parameters[1] = new SqlParameter("@TA_STATE", (int)notificationState);
            ExecuteNonQuery(sqlCommand, parameters);
        }
        public void UpdateAlertSleep(int alertID, DateTime sleepDate)
        {
            sqlCommand = "PRC_TB_ALERTS_SLEEP_UP";
            SqlParameter[] parameters = new SqlParameter[2];
            parameters[0] = new SqlParameter("@TA_ID", alertID);
            parameters[1] = new SqlParameter("@TA_SLEEP_DATE", sleepDate != DateTime.MinValue ? sleepDate : (object)DBNull.Value);
            ExecuteNonQuery(sqlCommand, parameters);
        }
        public void SendMicrosoftOutLookEMail(String subject, String htmlMessage, String[] emails)
        {
            try
            {
                // Create the Outlook application.
                Outlook.Application oApp = new Outlook.Application();

                // Get the NameSpace and Logon information.
                Outlook.NameSpace oNS = oApp.GetNamespace("mapi");

                // Log on by using a dialog box to choose the profile.
                oNS.Logon(Missing.Value, Missing.Value, true, true);

                // Alternate logon method that uses a specific profile.
                // TODO: If you use this logon method, 
                //  change the profile name to an appropriate value.
                //oNS.Logon("YourValidProfile", Missing.Value, false, true); 

                // Create a new mail item.
                Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

                // Set the subject.
                oMsg.Subject = subject;

                // Set HTMLBody.
                oMsg.HTMLBody = htmlMessage;

                // Add a recipient.
                Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
                if (emails != null && emails.Length > 0)
                {
                    foreach (String itemAddress in emails)
                    {
                        Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add(itemAddress);
                        oRecip.Resolve();
                        oRecip = null;
                    }
                }

                // Send.
                oMsg.Send();

                // Log off.
                oNS.Logoff();

                // Clean up.
                oRecips = null;
                oMsg = null;
                oNS = null;
                oApp = null;
            }
            // Simple error handling.
            catch (Exception ex)
            {
                throw new ExceptionHandling.GeneralException("Não foi possível enviar o e-mail de alerta através do Microsoft Outlook.\r\nVerifique as configurações de e-mail ou a instalação do Microsoft Outlook", ex);
            }
        }
    }
}
